using System.Collections.Generic;
using UnityEngine;

namespace MLTimeline
{
    [System.Serializable]
    public class Track
    {
        public string trackName = "New Track";
        public bool isMuted = false;
        [SerializeReference]
        public List<IClip> clips = new();

        public int MaxFrameCount { get; private set; }

#if UNITY_EDITOR
        /// <summary>
        /// 编辑器界面下的轨道高度
        /// </summary>
        public float height = 50f;
#endif

        public virtual void Initialize(Timeline timelineData)
        {
            for (var i = 0; i < clips.Count; i++)
            {
                if (clips[i] == null) continue;
                clips[i].Initialize(timelineData);
                MaxFrameCount = Mathf.Max(MaxFrameCount, clips[i].EndFrame);
            }
            OnInitialize(timelineData);
        }

        public virtual void OnInitialize(Timeline timelineData) { }
    }
}